<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>CheckOut</title>
</head>
<body>
    <div th:replace="common/Top"></div>

    <div id="Content">
        <div id="BackLink">
            <a href="/cart/viewCart">Return to Shopping Cart</a>
        </div>

        <div id="Catalog">
            <form action="/order/newOrderForm" method="post">
                <h2>Checkout Summary</h2>
                <table>
                    <tr>
                        <td><b>Item ID</b></td>
                        <td><b>Product ID</b></td>
                        <td><b>Description</b></td>
                        <td><b>In Stock?</b></td>
                        <td><b>Quantity</b></td>
                        <td><b>List Price</b></td>
                        <td><b>Total Cost</b></td>
                    </tr>

                    <tr th:each="cartItem:${session.cart.cartItems}">
                        <td>
                            <a th:href="@{/catalog/viewItem?itemId={itemId}(itemId=${cartItem.itemId})}" name="itemId" th:value="${cartItem.itemId}" th:text="${cartItem.itemId}"></a>
                        </td>
                        <td th:text="${cartItem.productId}"></td>
                        <td th:text="${cartItem.descn}"></td>
                        <td th:text="${cartItem.inStock}"></td>
                        <td th:text="${cartItem.quantity}"></td>
                        <td th:text="'$'+${#numbers.formatDecimal(cartItem.listPrice,0,'COMMA',2,'POINT')}"></td>
                        <td th:text="'$'+${#numbers.formatDecimal(cartItem.totalPrice,0,'COMMA',2,'POINT')}"></td>
                    </tr>

                    <tr>
                        <td colspan="7">
                            Sub Total: <span th:text="'$'+${#numbers.formatDecimal(session.cart.subTotal,0,'COMMA',2,'POINT')}"></span>
                        </td>
                    </tr>
                </table>
                <input type="submit" id="confirmOrder" value="confirmOrder">
            </form>
        </div>
    </div>

    <div th:replace="common/Bottom"></div>
</body>
</html>